#ifndef _FENGINE_FREE_CAMERA_HANLDER
#define _FENGINE_FREE_CAMERA_HANLDER

namespace FEngine
{
	class Camera;

	/**
	 * Model of camera that can be controlled using the mouse and the WASD key.
	 * The controls are :
	 *		- WASD to move forward, backward and sideways
	 *		- MAJ to boost the move speed
	 *		- QE to move up and down
	 *		- Mouse movement while the left button is down to rotate
	 */
	class FreeCameraHandler : public Node, public MouseInputListener
	{
		private:

			Camera*				mCamera;
			
			Node*				mRotX;
			Node*				mRotY;
			Node*				mLookAtPos;
			
			Vector2				mMouseMovement;
			float				mRotationX;
			float				mRotationY;

			int					mMoveSpeed;
			float				mRotationSpeedX;		// Angle of the rotation for each pixel of mouse movement
			float				mRotationSpeedY;		// Angle of the rotation for each pixel of mouse movement


		public:

			/**
			 * Constructor
			 * @param _cam Pointor to the camera to control.
			 * @param _pos Initial position of the camera.
			 * @param _lookDir Initial look direction of the camera.
			 */
			FreeCameraHandler(Camera* _cam, const Vector3& _pos, const Vector3& _lookDir);
			~FreeCameraHandler();

			/**
			 * Set the camera movement speed.
			 * @param _speed Movement speed of the camera.
			 */
			void setMovementSpeed(int _speed);


		protected:
			
			virtual void update(double _elapsedTime);

			virtual void mouseButtonPressed(int _button, const Vector2& _position);
			virtual void mouseButtonReleased(int _button, const Vector2& _position);
			virtual void mouseMoved(const Vector2& _delta);

	};
}

#endif
